using Commons.Models.OperationsContext;
using Commons.Utils;
using System;

namespace Commons.Models.Locks
{
	public class DateUnlockConditionChecker : IUnlockConditionChecker
	{
		public bool CheckCondition(IUnlockCondition condition, IOperationContext context)
		{
			DateUnlockCondition dateCondition = condition as DateUnlockCondition;

			DateTime now = DateTimeHelper.Current();

			if (dateCondition.From != null && dateCondition.From > now)
			{
				return false;
			}

			if (dateCondition.To != null && dateCondition.To < now)
			{
				return false;
			}

			return true;
		}
	}
}

